package org.dubnation.auth.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.dubnation.auth.service.IPermissionService;
import org.dubnation.auth.domain.Permission;
import org.dubnation.auth.query.PermissionQuery;
import org.dubnation.base.util.AjaxResult;
import org.dubnation.base.util.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/permission")
@Api(value = "权限管理",description = "权限管理")
public class PermissionController {

    @Autowired
    public IPermissionService permissionService;

    /**
    * 查看所有的员工信息
    * @return
    */
    @ApiOperation(value = "查询所有权限数据")
    @GetMapping
    public AjaxResult queryAll(){
        List<Permission> permissions = permissionService.queryAll();
        return AjaxResult.me().setData(permissions);
    }

    /**
    * 分页查询数据
    *
    * @param query 查询对象
    * @return PageList 分页对象
    */
    @ApiOperation(value = "分页查询权限数据")  @ApiParam(value = "关键字、当前页、每页条数",required = true)
    @PostMapping
    public AjaxResult queryPage( @RequestBody PermissionQuery query) {
        PageInfo<Permission> pageInfo = permissionService.queryPage(query);
        return AjaxResult.me().setData(pageInfo);
    }
}
